<template>
  <div class="bg-white rounded-lg p-5 h-full">
    <div class="font-bold text-lg mb-4">添加记分类型表</div>
    <el-form :model="editForm" :rules="rules" ref="form" label-width="80px">
      <el-form-item label="记分" prop="score">
        <el-input-number
          style="width: 240px"
          v-model="editForm.score"
          placeholder="请输入记分"
        />
      </el-form-item>
      <el-form-item label="记分原因" prop="reason">
        <el-input
          type="textarea"
          style="width: 240px"
          v-model="editForm.reason"
          placeholder="请输入记分原因"
        />
      </el-form-item>
    </el-form>
    <hr class="my-4" />
    <div class="flex">
      <el-button @click="submit" type="primary">确认</el-button>

      <el-button @click="goBack">返回</el-button>
    </div>
  </div>
</template>

<script>
import { addScoringTypeAPI } from "@/api/zhangping/health-care/org-scoring";
export default {
  data() {
    return {
      editForm: {},
      params: {
        id: null,
      
        enterpriseName: null,
        creditCode: null,
      },
      rules: {
        score: [
          {
            required: true,
            message: "请输入记分",
            trigger: "change",
          },
        ],
        reason: [
          {
            required: true,
            message: "请输入原因",
            trigger: "change",
          },
        ],
      },
    };
  },

  watch: {},
  computed: {},
  created() {},
  methods: {
    goBack() {
      this.$router.back();
    },
    // 确认
    submit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          const params = {
            recordType:this.$store.state.hospital.recordType,
            score: this.editForm.score, // 记分
            reason: this.editForm.reason, // 记分原因
          };
          addScoringTypeAPI(params).then((res) => {
            if(res.code===200){

                this.$message({
                  message: "添加成功",
                  type: "success",
                });
                this.$router.push({ path: "/health-care/org-scoring-type" });
            }
          });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>

<style scoped="scoped" lang="scss"></style>
